import fetch from 'common/src/utils/fetch'
import UTILS from "common/src/utils/utils";
function getCoursemessage(code) {//查询课程信息
    return fetch({
        url: '/api/scoremanagementservice/ScoreCourseWhiteBachelor/selectCourseInfo?code=' + code,
        method: 'get',

    })
}
function getScoreRecordMethods(data) {//获取成绩记录方式
    return fetch({
        url: '/api/scoremanagementservice/scoreEnterAffirm/queryScoreEnterAffirmBachelor',
        method: 'post',
        data
    })
}
function getScopeTypeList(data) {
    return fetch({
        url: '/api/scoremanagementservice/scoreSettingController/queryScoreRecord?coretypeCode=' + data + '&projectId=1',
        method: 'get'
    })
}
function queryStudentCourseInfo(id) {//查询学生信息
    return fetch({
        url: '/api/scoremanagementservice/scoreMaintenance/queryStudentInfoByCode?studentCode=' + id + '&projectId=1',
        method: 'get',
    })
}
function addScore(data) {//添加成绩
    return fetch({
        url: '/api/scoremanagementservice/scoreMaintenance/batchEnterResultBachelor',
        method: 'post',
        data
    })
}
function autoAddScore(data, type) {//5分钟自动保存成绩//type:1调保存接口，2：五分钟自动保存
    return fetch({
        url: '/api/scoremanagementservice/scoreMaintenance/batchEnterResultBachelor',
        method: 'post',
        data,
        showMask: type == 1 ? true : false
    })
}
function getTableList(data) {//学生列表
    return fetch({
        url: '/api/scoremanagementservice/scoreMaintenance/queryScoreResultBachelorPage',
        method: 'post',
        data
    })
}
function batchDeleteScoreList(data) {//删除
    return fetch({
        url: '/api/scoremanagementservice/scoreMaintenance/batchDelScoreResultBachelor',
        method: 'delete',
        data
    })
}
function exportListData(param, ids) {//导出
    return fetch({
        url: '/api/scoremanagementservice/scoreMaintenance/exportScoreResultRound',
        params: param,
        method: 'post',
        headers: { 'Content-Type': 'text/plain;charset=UTF-8' },
        data: ids,
    })
    // .then(res => {
    //     UTILS.downloadFile(res, '学生成绩维护.xls', 'application/vnd.ms-excel;charset=utf-8');
    // });
}
function exportScoreResultRoundByKey(key) {
    return fetch({
        url: `/api/scoremanagementservice/scoreMaintenance/exportScoreResultRoundByKey?key=${key}`,
        method: 'GET'
    });
}
function getCourseLabelList(calendarId) {
    return fetch({
        url: '/api/scoremanagementservice/scoreMaintenance/queryCourseLabelsByCulture?calendarId=' + calendarId,
        method: 'get'
    })

}

function getChildScoreList(id, calendarId, keepField) {
    return fetch({
        url: `/api/scoremanagementservice/scoreMaintenance/queryEnterResultBachelor?id=${id}&calendarId=${calendarId}&keepField=${keepField}`,
        method: 'get'
    })
}
function editScore(data) {
    return fetch({
        url: '/api/scoremanagementservice/scoreMaintenance/updateScoreResultBachelor',
        data,
        method: 'post'
    })
}

function getChildScoreInfo(data) {
    return fetch({
        url: '/api/scoremanagementservice/enterScoreController/initTeachingclassInfo',
        data,
        method: 'post'
    })
}
//短信验证
function sendSms(data) {
    return fetch({
        url: '/api/scoremanagementservice/enterScoreController/sendSms',
        data,
        method: 'post'
    })
}
function validationSms(data) {
    return fetch({
        url: '/api/scoremanagementservice/enterScoreController/validationSms',
        data,
        method: 'post'
    })
}
export default {
    getCoursemessage,
    getScoreRecordMethods,
    queryStudentCourseInfo,
    getScopeTypeList,
    addScore,
    getTableList,
    batchDeleteScoreList,
    exportListData,
    exportScoreResultRoundByKey,
    getCourseLabelList,
    getChildScoreList,
    editScore,
    getChildScoreInfo,
    sendSms,
    validationSms,
    autoAddScore
}